<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .bg{
            background-color: yellow;
        }
    </style>
   
</head>
<body>
    <div></div>
    <script>
        var users={
            name:"alice",
            address:[
                {
                    hometown:"第一故乡",
                    addName:"南京"
                },
                {
                    hometown:"第二故乡",
                    addName:"盐城"
                },
                {
                    hometown:"第三故乡",
                    addName:"南通"
                }
            ]
        };
        var div=document.querySelector("div");
        // for(var i=0;i<users.address.length;i++){
        //     // console.log(users.address[i]);//单个对象
        //     var p=document.createElement("p");
        //     p.innerHTML=users.address[i].hometown+":"+users.address[i].addName;
        //     div.appendChild(p);

        // }

        var str="";
        for(var i=0;i<users.address.length;i++){
            str+="<p class='bg'>"+users.address[i].hometown+":"+users.address[i].addName+"</p>";
          
        }
        div.innerHTML=str;
       
    </script>
</body>
</html>